<?php
class student extends CI_Controller{
    function __construct(){
        parent::__construct();
        // Your own constructor code
    }
    function index(){
        $this->load->model('Model_student');
        if($this->Model_student->is_logged_in()){
            $student_id=$this->session->userdata("student_id");
            $student=$this->Model_student->student_info($student_id);
            $data['student_name']=$student->student_name;

            $this->load->view('student/student_index',$data);
           
        }else{
            redirect("student/login");
        }
         $this->load->view('student/index');
    }
    function check_status(){
        if(isset($_POST['submit'])){
            $student_name = trim($_POST['student_name']);
            $password = trim($_POST['password']);
             $this->load->model('Model_student');
            $found_student_id=$this->Model_student->authenticate($student_name,$password);
            if($found_student_id){
                $this->Model_student->login($found_student_id);
                redirect("student/index");
            }else{
                redirect("student/login");
            }            
        }
    }
    public function login(){
        $this->load->view('student/login');
    }
    function logout(){
        $this->load->model('Model_student');
        $this->Model_student->logout();     
    }
  
}
    ?>
